/*s
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package auctions;
import java.util.*;


/**
 *
 * @author hangsu
 */
public class SequentialDummyAgent implements Agent {

    private AuctionHouse house;
    
    private Vector <AuctionType> auctionTypes;

    private AuctionHouseType houseType;

    private HashMap<Integer,Double> wonItems;
    
    private Vector <Integer> schedule;

    private Vector <Double> utilities;
    private Random _rand;
    
    public SequentialDummyAgent(AuctionHouse house, Vector<Double> utls){
        this.house=house;
        this.wonItems=new HashMap<Integer,Double>();
        this.utilities = utls;
        this.houseType = house.getType();
        this.auctionTypes = house.getAuctionTypes();
        _rand = new Random();

    }
    
    public void setSchedule(Vector <Integer> schd){
    	this.schedule = schd;
    }
    
    /*this method is for ascending/descending auction*/
    public double getBid(int auctionNumber, double askPrice, AuctionResults auctResults){

    	double bid = this.utilities.get(auctionNumber);
    	switch (this.auctionTypes.get(auctionNumber)){
    	case ASCENDING:
    		if(bid<askPrice)
    			bid = 0.0;
    		else
    			bid = askPrice+_rand.nextDouble()*(bid-askPrice);
    		break;
    	case DESCENDING:
    		//TODO add dealing with descending
    		break;
    	default:
    		break;
    	}
    		


	    return bid;
    }
    
	@Override
	/*this method is for descending acution*/
	public double getBid(int auctionNumber, double askPrice) {
		// TODO Auto-generated method stub
		return 0;
	}
    
    /*this method is for sealed-bid auction*/
    public double getBid(int auctionNumber){
        double bid = this.utilities.get(auctionNumber);
   

        return bid;
    }

    public void addWinnings(int itemNumber, double price){
        wonItems.put(itemNumber, price);
    }

    public double getUtility(int num){
    
        return utilities.get(num);
    }

	@Override
	public void submitResults(AuctionResults r) {
		// TODO Auto-generated method stub
		
	}
}
